﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace XF.Common
{
    public static class DataGridViewHelper
    {

        /// <summary>
        /// 获取选中行索引
        /// </summary>
        /// <returns></returns>
        public static List<int> GetSelectedRowsIndex(this DataGridView dgv)
        {
            List<int> indexs = new List<int>();
            for (int i = 0; i < dgv.SelectedCells.Count; i++)
            {
                if (!indexs.Contains(dgv.SelectedCells[i].RowIndex))
                {
                    indexs.Add(dgv.SelectedCells[i].RowIndex);
                }
            }
            return indexs;
        }
    }
}
